package com.syx.service.impl;

import com.syx.dao.ArtDao;
import com.syx.entity.Article;
import com.syx.service.ArtService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArtServiceImpl implements ArtService {
    @Resource
    private ArtDao artDao;

    @Override
    public List artList(Map map) {
        return artDao.artList(map);
    }

    @Override
    public List tagList() {
        return artDao.tagList();
    }

    @Override
    public int add(Article article, Integer[] tagids) {
        int i = artDao.add(article);
        if (i>0){
            Map map = new HashMap();
            map.put("artid",article.getId());
            map.put("tagids",tagids);
            artDao.atAdd(map);
        }
        return i;
    }

    @Override
    public int del(Integer id) {
        int i = artDao.del(id);
        if (i>0){
            artDao.atDel(id);
        }
        return i;
    }

    @Override
    public Map hx(Integer id) {
        return artDao.hx(id);
    }
}
